package com.cta.dao;

import java.util.List;

import com.cta.entity.BaseEntity;
import com.cta.utils.SupportLoaderDelegate;

public interface BasePersistence {

	<T extends BaseEntity> List<T> getList(String sql, Object... params);

	public <T extends BaseEntity> List<T> getListWithArray(final String queryString, final Object[] params);

	<T extends BaseEntity> List<T> getList(final String queryString, final int firstResult, final int maxResult,
			final Object... params);

	<T extends BaseEntity> T save(T entity);

	public <T extends BaseEntity> void insert(T entity);

	<T extends BaseEntity> T findById(Class<T> clazz, Object id);

	public <T extends BaseEntity> List<T> getList(String sql, SupportLoaderDelegate<T> loader, Object... params);

	public <T extends BaseEntity> List<T> getList(final String queryString, SupportLoaderDelegate<T> loader,
			final int firstResult, final int maxResult, final Object... params);

	public <T extends BaseEntity> List<T> getListWithNativeSql(final Class<T> clazz, final String queryString,
			SupportLoaderDelegate<T> loader, final int firstResult, final int maxResult, final Object... params);

	public <T> List<T> getListWithNativeSql(final String queryString, SupportLoaderDelegate<T> loader,
			final int firstResult, final int maxResult, final Object... params);

	public <T extends BaseEntity> T findById(Class<T> clazz, Object id, SupportLoaderDelegate<T> loader);

	public <T extends BaseEntity> void delete(T entity);

	public int execute(final String queryString, final Object... values);

	public <T extends BaseEntity> List<T> findByProperty(Class<T> entityClass, SupportLoaderDelegate<T> loader,
			String propertyName, final Object value);

	public <T extends BaseEntity> List<T> findByProperty(Class<T> entityClass, String propertyName, final Object value);

	public <T extends BaseEntity> T findSingleObject(Class<T> entityClass, String propertyName, final Object value);

	public <T extends BaseEntity> T findSingleObject(String queryString, Object... params);

	public <T extends BaseEntity> void update(T entity);

	public long countObjects(String countQuery, Object... params);

	public long sumObjects(String countQuery, Object... params);

	public long countObjectsWithNativeSql(final String queryString, final Object... params);

	public <T> List<T> getListWithNativeSql(final String queryString,
			final Object[] params);
}
